#include <bits/stdc++.h>
using namespace std;
int t;
struct node{
    int d,v,a;
}car[100005];
int p[100005];
int cnt[100005];
void solve() {
    int n,m,L,V,ans = 0;
    cin >> n >> m >> L >> V;
    for (int i = 1; i <= n; i++) {
        cin >> car[i].d >> car[i].v >> car[i].a;
    }
    for (int i = 1; i <= m; i++) cin >> p[i];
    for (int i = 1; i <= m; i++) {
        bool is = false;
        for (int j = 1; j <= n; j++) {
            if (p[i] - car[j].d < 0) continue;
            int s = p[i] - car[j].d;
            int v = car[j].v * car[j].v + 2 * car[j].a * s;
            if (car[i].a == 0 || s == 0) v = car[i].v;
            if (v > V * V && !is) {
                ans++;
                is = true;
            }
            if (v > V * V) {
                cnt[i]++;
            }
        }
    }
    int ans2 = 0;
    for (int i = 1; i <= m; i++) if (cnt[i] == 0) ans2++;
    cout << ans << " " << ans2;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",sdout);
    cin >> t;
    while (t--) {
       solve();
    }
    return 0;
}
